<?php
/**
 * Created by PhpStorm.
 * User: sunku
 * Date: 2018/1/2
 * Time: 9:51
 */

namespace Admin\Transformer;
use Common\ORG\Util\Transformer;

class CustomerTransformer extends Transformer
{
    public function Transformer($item)
    {
        //类别
        $typeList = C('CUSTOMER_TYPE');
        //等级
        $levelList = C('CUSTOMER_LEVEL');
        //状态
        $statusList = C('CUSTOMER_STATUS');
        //阶段
        $phaseList = C('CUSTOMER_PHASE');
        return [
            'id' => intval($item['id']),
            'company_name' => strval($item['company_name']),
            'name' => strval($item['name']),
            'admin_id' => intval($item['admin_id']),
            'gender' => intval($item['gender']),
            'gender_desc' => ($item['gender']==1)?'男':'女',
            'admin_name' => strval($item['admin_name']),
            'product_name' => strval($item['product_name']),
            'order_id' => isset($item['order_id'])?$item['order_id']:0,
            'order_status' => isset($item['order_status'])?intval($item['order_status']):0,
            'first_name' => isset($item['first_name'])?strval($item['first_name']):'',
            'second_name' => isset($item['second_name'])?strval($item['second_name']):'',
            'department_name' => isset($item['department_name'])?strval($item['department_name']):'',
            'mobile' => strval($item['mobile']),
            'tel' => strval($item['tel']),
            'wechat' => strval($item['wechat']),
            'qq' => strval($item['qq']),
            'status' => intval($item['status']),
            'status_desc' => $statusList[$item['status']],
            'level' => intval($item['level']),
            'level_desc' => $levelList[$item['level']],
            'type' => intval($item['type']),
            'type_desc' => $typeList[$item['type']],
            'cid' => intval($item['cid']),
            'second_cid' => intval($item['second_cid']),
            'phase' => intval($item['phase']),
            'applicant_id' => intval($item['applicant_id']),
            'old_id' => intval($item['old_id']),
            'phase_desc' => $phaseList[$item['phase']],
            'refuse_reason' => strval($item['refuse_reason']),
            'upfile' => strval($item['upfile']),
            'create_time' => date('Y-m-d', $item['create_time']),
            'archive_time' => $item['archive_time']?date('Y-m-d', $item['archive_time']):'-',
            'update_time' => date('Y-m-d', $item['update_time']),
        ];
    }
}